﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HPCERP.Model;

namespace HPCERP.BusinessObject
{
    public class BankBO
    {
        hpc_erpEntities ctx = new hpc_erpEntities();
               
        public Bank[] GetList(int id_Company)
        {
            var banks = from c in ctx.Bank where c.Company.ID_Company == id_Company orderby c.ID_Bank select c;
            return banks.ToArray();
        }

        public void Insert(Bank bank)
        {
            ctx.Bank.AddObject(bank);
            ctx.SaveChanges();
        }

        public void Update(Bank bank)
        {
            ctx.Bank.ApplyChanges(bank);
            ctx.SaveChanges();
        }

        public void Delete(int id)
        {
            var bank = (from c in ctx.Bank where c.ID_Bank == id select c).First();
            ctx.Bank.DeleteObject(bank);
            ctx.SaveChanges();
        }
    }
}
